#ifndef ERRORSHH
#define ERRORSHH
#include "stdincludes.hh"
#include <execinfo.h>

namespace licada
{
    class LicadaError : public std::exception
    {
	std::string stackTrace;
    public:
	LicadaError() {
	    using namespace std;

	    
	    void *array[25];
	    size_t size;
	    char **strings;
	    size_t i;
	    std::ostringstream stringbuf;
	    
	    size = backtrace (array, 25);
	    strings = backtrace_symbols (array, size);

	    
	    for (i = 0; i < size; i++)
		stringbuf << strings[i] << endl;
	    
	    stackTrace = stringbuf.str();
	    free (strings);
	}
	LicadaError( const std::string& _stackTrace ) : stackTrace( _stackTrace ){}
	virtual ~LicadaError() throw(){}

	const std::string& getStackTrace() const { return stackTrace; }
    };
}
#endif
